//
//  main.m
//  Jajeo
//
//  Created by steven.zhan on 14-9-11.
//  Copyright (c) 2014年 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import "SimulateTouch.h"


static void do_fst_task(int t);
static void do_sec_task(int t);
static void do_thr_task(int t);
static void do_fight();
static void get_income();

int r=0;

int main (int argc, const char * argv[])
{
    @autoreleasepool
    {
        NSLog(@"======touch everyday_sport begin=====");
        r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(300, 45) withType:STTouchDown];
        [SimulateTouch simulateTouch:r atPoint:CGPointMake(300, 45) withType:STTouchUp];
        NSLog(@"======touch everyday_sport end=====");
        
        //1.第一个任务
        //do_fst_task(10);
        
        //2.第二个任务
        //do_sec_task(3);
        
        //3.时光之主
        do_thr_task(2);


    }
	return 0;
}

static void do_thr_task(int t)
{
    sleep(1);
    r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(120, 120) withType:STTouchDown];
    [SimulateTouch simulateTouch:r atPoint:CGPointMake(120, 120) withType:STTouchUp];
    
    while (t) {
        
        //1.点击副本
        sleep(1);
        r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(190, 360) withType:STTouchDown];
        [SimulateTouch simulateTouch:r atPoint:CGPointMake(190, 360) withType:STTouchUp];
        
        sleep(1);
        r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(150, 360) withType:STTouchDown];
        [SimulateTouch simulateTouch:r atPoint:CGPointMake(150, 360) withType:STTouchUp];
        
        do_fight();
        
        sleep(1);
        r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(260, 80) withType:STTouchDown];
        [SimulateTouch simulateTouch:r atPoint:CGPointMake(260, 80) withType:STTouchUp];
        
        sleep(480);
        t--;
    }

    
}

void do_fst_task(int t)
{
    NSLog(@"======do fs  begin=====");
    
    sleep(1);
    r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(120, 120) withType:STTouchDown];
    [SimulateTouch simulateTouch:r atPoint:CGPointMake(120, 120) withType:STTouchUp];
    
    //1.点击副本 (第三章第一个副本坐标)
    r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(155, 366) withType:STTouchDown];
    [SimulateTouch simulateTouch:r atPoint:CGPointMake(155, 366) withType:STTouchUp];
    
    while (t) {
        do_fight();
        t--;
    }
    
    get_income();
    //6.返回task_list菜单
    NSLog(@"======do fs end=====");
}

static void do_sec_task(int t)
{
    sleep(1);
    r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(120, 120) withType:STTouchDown];
    [SimulateTouch simulateTouch:r atPoint:CGPointMake(120, 120) withType:STTouchUp];
    
    //1.点击副本 (第三章第一个副本坐标)
    sleep(1);
    r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(155, 400) withType:STTouchDown];
    [SimulateTouch simulateTouch:r atPoint:CGPointMake(155, 400) withType:STTouchUp];
    
    while (t) {
        do_fight();
        t--;
    }
    
    sleep(1);
    r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(260, 80) withType:STTouchDown];
    [SimulateTouch simulateTouch:r atPoint:CGPointMake(260, 80) withType:STTouchUp];
    
    get_income();
}

static void do_fight()
{
        //2.首页开始
        sleep(1);
        r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(280, 40) withType:STTouchDown];
        [SimulateTouch simulateTouch:r atPoint:CGPointMake(280, 40) withType:STTouchUp];
        //3.次页开始
        sleep(1);
        r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(280, 40) withType:STTouchDown];
        [SimulateTouch simulateTouch:r atPoint:CGPointMake(280, 40) withType:STTouchUp];
        sleep(5);
        //3.自动
        r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(280, 20) withType:STTouchDown];
        [SimulateTouch simulateTouch:r atPoint:CGPointMake(280, 20) withType:STTouchUp];
        //4.重新开始
        sleep(100);
        r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(100, 60) withType:STTouchDown];
        [SimulateTouch simulateTouch:r atPoint:CGPointMake(100, 60) withType:STTouchUp];
}

static void get_income()
{
    //4.返回
    sleep(1);
    r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(20, 460) withType:STTouchDown];
    [SimulateTouch simulateTouch:r atPoint:CGPointMake(20, 460) withType:STTouchUp];
    
    //5.返回
    sleep(1);
    r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(20, 460) withType:STTouchDown];
    [SimulateTouch simulateTouch:r atPoint:CGPointMake(20, 460) withType:STTouchUp];
    
    //6.完成任务
    sleep(1);
    r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(105, 100) withType:STTouchDown];
    [SimulateTouch simulateTouch:r atPoint:CGPointMake(105, 100) withType:STTouchUp];
    
    //7.领取奖励
    sleep(1);
    r=[SimulateTouch simulateTouch:0 atPoint:CGPointMake(200, 240) withType:STTouchDown];
    [SimulateTouch simulateTouch:r atPoint:CGPointMake(200, 240) withType:STTouchUp];
}



